package com.lxn.hrm.feignclients;


import com.lxn.hrm.fallback.RedisFeignClientFallbackFactory;
import com.lxn.hrm.util.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

//value属性：调用目标服务的服务名   //走托底方法
@FeignClient(value="redis-server", fallbackFactory = RedisFeignClientFallbackFactory.class)
public interface RedisFeignClient {

    //目标服务的controller的方法，拷贝过来，修改
    //设置值
    @PostMapping("/redis/set")
    AjaxResult set(@RequestParam("key") String key , @RequestParam("value") String value);

    @PostMapping("/redis/setex")
    AjaxResult setex(@RequestParam("key") String key,@RequestParam("seconds") int seconds ,@RequestParam("value") String value);

    //获取值
    @GetMapping("/redis/get/{key}")
    AjaxResult get(@PathVariable("key") String key);
}
